// 游游的you
#include <iostream>
using namespace std;

int main() {
    int q;
    cin >> q;
    while(q--)
    {
        int y, o, u;
        cin >> y >> o >> u;
        int x = min(y,min(o, u));
        cout << (2 * x + max(0, (o - x - 1))) << endl;
    }
    return 0;
}

// 腐烂的苹果
class Solution {
    public:
        bool vis[1001][1001] = {false};
        int dx[4] = {0, 0, 1, -1};
        int dy[4] = {1, -1, 0, 0};
        int m, n;
        int rotApple(vector<vector<int> >& grid) {
            m = grid.size(), n = grid[0].size();
            queue<pair<int,int>> q;
            for(int i = 0; i < m; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if(grid[i][j] == 2)
                        q.push({i, j});
                }
            }
            int ret = 0;
            while(q.size())
            {
                int sz = q.size();
                ++ret;
                while(sz--)
                {
                    auto [a, b] = q.front();
                    q.pop();
                    for(int k = 0; k < 4; k++)
                    {
                        int x = a + dx[k], y = b + dy[k];
                        if(x >= 0 && x < m && y >= 0 && y < n && !vis[x][y] && grid[x][y] == 1)
                        {
                            vis[x][y] = true;
                            q.push({x, y});
                        }
                    }
                }
            }
            for(int i = 0; i < m; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if(grid[i][j] == 1 && !vis[i][j])
                        return -1;
                }
            }
            return ret - 1;
        }
    };

    // 孩子们的游戏
    class Solution {
        public:
        
            int LastRemaining_Solution(int n, int m) {
                int ret = 0;
                for(int i = 2; i <= n; i++)
                    ret = (ret + m) % i;
                return ret;
            }
        };


// 大数加法
#include <iterator>
#include <string>
class Solution {
public:
    string solve(string s, string t) {
        string ret;
        int i = s.size() - 1, j = t.size() - 1;
        int tmp = 0;
        while(i >= 0 || j >= 0 || tmp)
        {
            if(i >= 0) tmp += s[i--] - '0';
            if(j >= 0) tmp += t[j--] - '0';
            ret += (tmp % 10) + '0';
            tmp /= 10;
        }
        reverse(ret.begin(), ret.end());
        return ret;
    }
};

// 链表相加(二)
/**
 * struct ListNode {
 *	int val;
 *	struct ListNode *next;
 *	ListNode(int x) : val(x), next(nullptr) {}
 * };
 */
class Solution {
    public:
        ListNode* reverse(ListNode* head)
        {
            ListNode *newhead = new ListNode(-1);
            ListNode* cur = head;
            while(cur)
            {
                ListNode *next = cur->next;
                cur->next = newhead->next;
                newhead->next = cur;
                cur = next;
            }
            cur = newhead->next;
            delete newhead;
            return cur;
        }
        ListNode* addInList(ListNode* head1, ListNode* head2) {
            head1 = reverse(head1);
            head2 = reverse(head2);
    
            ListNode *newhead = new ListNode(-1);
            ListNode* prev = newhead;
            ListNode *l1 = head1, *l2 = head2;
            int tmp = 0;
            while(l1 || l2 || tmp)
            {
                if(l1)
                {
                    tmp += l1->val;
                    l1 = l1->next;
                }
                if(l2)
                {
                    tmp += l2->val;
                    l2 = l2->next;
                }
                prev->next = new ListNode(tmp % 10);
                prev = prev->next;
                tmp /= 10;
            }
            prev = newhead->next;
            newhead->next = nullptr;
            delete newhead;
            prev = reverse(prev);
            return prev;
        }
    };

// 大数乘法
    class Solution {
        public:
            string solve(string s, string t) {
                reverse(s.begin(), s.end());
                reverse(t.begin(), t.end());
                int m = s.size(), n = t.size();
        
                vector<int> tmp(m + n);
                for(int i = 0; i < m; i++)
                    for(int j = 0; j < n; j++)
                        tmp[i + j] += (s[i] - '0') * (t[j] - '0');
                    
                int c = 0;
                string ret;
                for(auto x : tmp)
                {
                    c += x;
                    ret += c % 10 + '0';
                    c /= 10;
                }
                while(c)
                {
                    ret += c % 10 + '0';
                    c /= 10;
                }
                while(ret.size() > 1 && ret.back() == '0') ret.pop_back();
                reverse(ret.begin(), ret.end());
                return ret;
            }
        };